package ${package}.modules.${functionName}.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yf.exam.core.api.ApiRest;
import com.yf.exam.core.api.controller.BaseController;
import com.yf.exam.core.api.dto.BaseIdReqDTO;
import com.yf.exam.core.api.dto.BaseIdsReqDTO;
import com.yf.exam.core.api.dto.BaseStateReqDTO;
import com.yf.exam.core.api.dto.PagingReqDTO;
import com.yf.exam.modules.${functionName}.dto.${ClassName}DTO;
import com.yf.exam.modules.${functionName}.dto.request.${ClassName}SaveReqDTO;

import com.yf.exam.modules.${functionName}.entity.${ClassName};
import com.yf.exam.modules.${functionName}.service.${ClassName}Service;
import io.swagger.annotations.Api;
import com.yf.exam.core.api.dto.BaseIdRespDTO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;


/**
* ${tableComment}
*
* @author ${author} ${email}
* @since ${version} ${date}
*/

@Api(tags={"${tableComment}"})
@RestController
@RequestMapping("/exam/api/${functionName}/${functionName}")
public class ${ClassName}Controller extends BaseController {
    @Autowired
    private  ${ClassName}Service baseService;


    /**
    * 添加或修改
    *
    * @param reqDTO
    * @return
    */
    @ApiOperation(value = "添加或修改")
    @RequestMapping(value = "/save", method = {RequestMethod.POST})
    public ApiRest<BaseIdRespDTO> save(@RequestBody ${moduleName}SaveReqDTO reqDTO) {
        baseService.save(reqDTO);
        return super.success();
    }

    /**
    * 批量删除
    *
    * @param reqDTO
    * @return
    */
    @ApiOperation(value = "批量删除")
    @RequestMapping(value = "/delete", method = {RequestMethod.POST})
    public ApiRest edit(@RequestBody BaseIdsReqDTO reqDTO) {
        //根据ID删除
        baseService.delete(reqDTO.getIds());
        return super.success();
    }
    /**
    * 查找详情
    * @param reqDTO
    * @return
    */
    @ApiOperation(value = "查找详情")
    @RequestMapping(value = "/detail", method = { RequestMethod.POST})
    public ApiRest<${moduleName}DTO> find(@RequestBody BaseIdReqDTO reqDTO) {
        ${moduleName}DTO dto = baseService.findById(reqDTO.getId());
        return super.success(dto);
    }

    /**
    * 分页查找
    *
    * @param reqDTO
    * @return
    */
    @ApiOperation(value = "分页查找")
    @RequestMapping(value = "/paging", method = {RequestMethod.POST})
    public ApiRest<IPage<${moduleName}DTO>> paging(@RequestBody PagingReqDTO<${moduleName}DTO> reqDTO) {
          //分页查询并转换
          IPage<${moduleName}DTO> page = baseService.paging(reqDTO);
          return super.success(page);
    }


}